#!/bin/sh

dir=`dirname "$0"`
cd "$dir"
classpath=./:./lib/touchLibs/etc/fonts/fonts

for i in `ls ./lib`
do
    classpath=$classpath:./lib/$i
done

export DYLD_LIBRARY_PATH=.

# start the previewer
fileExtT=`echo $1 | awk -F. '{print $NF}'`
fileExt=`echo $fileExtT | tr '[:upper:]' '[:lower:]'`

if [ "$fileExt" == mobi -o "$fileExt" == azw3 -o "$fileExt" == epub -o "$fileExt" == opf -o  "$fileExt" == html -o  "$fileExt" == zip ]
then
    # opens only the first book in command line.  TODO: handle multiple books in command line
    java -d32 -XstartOnFirstThread -cp "${classpath}"  com.amazon.epub.reader.Main "$1"
    exit 1
else
    java -d32 -XstartOnFirstThread -cp "${classpath}"  com.amazon.epub.reader.Main
    exit 1
fi




